﻿namespace KinonekoSoftware.CodariaDB.Documents.Index
{
    public abstract class _Glossary : _Avatar, IGlossary, IGlossaryOperation
    {
        string IGlossary.Id => Id;

        string IGlossary.Intro => Intro;

        void IGlossaryOperation.Add(Engine engine)
        {
            engine.Queue
                  .OnNext(new ConceptOP_MSG
                   {
                       ConceptID       = Id,
                       ConceptIntro    = Intro,
                       ConceptName     = Name,
                       ConceptAvatar   = Avatar,
                       ConceptEngineID = engine.EngineID,
                       Action          = Database_Action.Added,
                   });
        }

        void IGlossaryOperation.Update(Engine engine)
        {
            engine.Queue
                  .OnNext(new ConceptOP_MSG
                   {
                       ConceptID     = Id,
                       ConceptIntro  = Intro,
                       ConceptName   = Name,
                       ConceptAvatar = Avatar,
                       Action        = Database_Action.Modified,
                   });
        }

        void IGlossaryOperation.Remove(Engine engine)
        {
            engine.Queue
                  .OnNext(new ConceptOP_MSG
                   {
                       ConceptID   = Id,
                       ConceptName = Name,
                       Action      = Database_Action.Removed,
                   });
        }
    }
}